<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<html>
<head>
    <script type="text/javascript" src="/voteup/resources/js/jquery-1.6.1.js"></script>
    <script type="text/javascript" src="/voteup/resources/js/jquery-autocomplete/jquery.autocomplete.js"></script>
    <script type="text/javascript" src="/voteup/resources/js/stylescript.js"></script>
    <script type="text/javascript" src="/voteup/resources/js/regscript.js"></script>
    <link rel="stylesheet" type="text/css"
          href="/voteup/resources/js/jquery-autocomplete/jquery.autocomplete.css">
    <title>Registration</title>
</head>


<body>
<c:import url="/WEB-INF/jsp/header.jsp"/>
<p align="center" style=""><a href="/voteup/index" style="text-align:right">back to login page</a></p>
<center><h1>Join us now!</h1>
    <c:if test="${not empty msg}">
        <font size="2" color="red"> ${msg}
        </font>
    </c:if>
    <table id="regtable" cellspacing="6" cellpadding="0">
        <form:form action="registration" method="POST" commandName="person">
            <tr>
                <td colspan="2" class="error"><form:errors path="lastName"/></td>
            </tr>
            <tr>
                <td>Lastname:</td>
                <td><form:input cssClass="inputtext" path="lastName" maxlength="30"/></td>
            </tr>
            <tr>
                <td colspan="2" class="error">
                    <form:errors path="firstName"/></td>
            </tr>
            <tr>
                <td>Firstname:</td>
                <td><form:input cssClass="inputtext" path="firstName" maxlength="30"/></td>
            </tr>
            <tr>
                <td colspan="2" class="error">
                    <form:errors path="middleName"/></td>
            </tr>
            <tr>
                <td>Middlename:</td>
                <td><form:input cssClass="inputtext" path="middleName" maxlength="30"/></td>
            </tr>

            <tr>
                <td colspan="2" class="error"><form:errors path="bday"/></td>
            </tr>
            <tr>
                <td colspan="2"><p align="center">Birthday: </p>

                    <p align="center">Day: <form:input cssClass="inputtext" path="bday" maxlength="2" size="2"/>
                        Month: <form:input cssClass="inputtext" path="bmonth" maxlength="2" size="2"/>
                        Year: <form:input cssClass="inputtext" path="byear" maxlength="4" size="4"/></p>
                </td>
            </tr>
            <tr>
                <td>University:</td>
                <td><form:select path="group.faculty.university.universityName" cssClass="inputtext"
                                 items="${universities}"
                                 id="university" size="1" onchange="setUnivername();"/></td>
            </tr>

            <tr>
                <td>Faculty:</td>
                <td><form:select path="group.faculty.facultyName" items="${faculties}" cssClass="inputtext" id="faculty"
                                 size="1"
                                 onchange="setFacultyname();"/></td>
            </tr>
            <tr>
                <td colspan="2" class="error">
                    <form:errors path="group.groupName"/></td>
            </tr>
            <tr>
                <td>Group:</td>
                <td><form:input cssClass="inputtext" id="group" autocomplete="off" path="group.groupName"
                                maxlength="30"/></td>
            </tr>
            <tr>
                <td colspan="2" class="error"><form:errors path="email"/></td>
            </tr>
            <tr>
                <td>E-mail:</td>
                <td><form:input path="email" cssClass="inputtext" maxlength="50"/></td>
            </tr>
            <tr>
                <td colspan="2" class="error"><form:errors path="password"/></td>
            </tr>
            <tr>
                <td>Password:</td>
                <td><form:password cssClass="inputtext" path="password" maxlength="30"/></td>
            </tr>
            <c:if test="${not empty error}">
                <tr>
                    <td colspan="2" class="error">${error}
                    </td>
                </tr>
            </c:if>
            <tr>
                <td>Confirm password:</td>
                <td><input type="password" class="inputtext" name="cpassword" value="" maxlength="30"></td>
            </tr>
            <tr>
                <td colspan="2">
                    <input type=submit class="inputbutton" value="Confirm"></td>
            </tr>
        </form:form>
    </table>
    <script type="text/javascript">
        setUnivername();
    </script>
</center>
</body>
</html>